package com.sanhuo.idms.service;

import com.sanhuo.idms.dao.DormIpMapper;
import com.sanhuo.idms.entity.DormIp;
import com.sanhuo.triild.Basic.BaseMapper;
import com.sanhuo.triild.Basic.BaseService;
import com.sanhuo.triild.annotation.MapperWire;
import com.sanhuo.utils.basic.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
@Transactional
public class DormIpService extends BaseService<DormIp> {
    @MapperWire
    private DormIpMapper dormIpMapper;

    @Override
    public BaseMapper<DormIp> getBaseMapper() {
        return dormIpMapper;
    }

    public void save(String ip, String dormId) {
        DormIp dormIp = new DormIp();
        dormIp.setId(StringUtil.UUID());
        dormIp.setDormId(dormId);
        dormIp.setIp(ip);
        dormIp.setUpdateTime(new Date());
        save(dormIp);
    }

    public DormIp findByDormId(String dormId) {
        return dormIpMapper.findByDormId(dormId);
    }

    public void update(String ip, String dormId) {
//        DormIp dormIp = findById(id)
    }
}
